package com.bbs.generator;

import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.TemplateType;
import org.junit.Test;

import java.util.Collections;

public class BbsGeneratorTest extends BaseGeneratorTest{

    /**
     * 数据库配置
     */
    private static final DataSourceConfig DATA_SOURCE_CONFIG = new DataSourceConfig
            .Builder("jdbc:mysql://localhost:3306/bbs?useSSL=false", "root", "654321")
            .schema("bbs")
            .build();

    @Test
    public void mapperGen() {
        AutoGenerator generator = new AutoGenerator(DATA_SOURCE_CONFIG);
        generator.template(templateConfig()
                .disable(TemplateType.CONTROLLER, TemplateType.SERVICE, TemplateType.SERVICEIMPL)
                .build());
        generator.strategy(strategyConfig()
                .addInclude("user", "forum", "forum_comment")
                .entityBuilder().enableLombok().fileOverride().build()
                .mapperBuilder().enableBaseColumnList().enableBaseResultMap().enableMapperAnnotation().fileOverride()
                .build());
        generator.global(globalConfig()
                .author("zty")
                .outputDir("D:\\javaProject\\springbootProject\\bbs\\bbs\\bbs-common\\src\\main\\java")
                .build());
        generator.packageInfo(packageConfig()
                .parent("com.bbs.common")
                .pathInfo(Collections.singletonMap(OutputFile.xml, "D:\\javaProject\\springbootProject\\bbs\\bbs\\bbs-common\\src\\main\\resources\\mapper"))
                .build());
        generator.execute();

    }

}
